package com.juno.cafeNoa.admin.util;

import android.content.Context;
import android.os.PowerManager;
import android.telephony.TelephonyManager;
import android.util.Log;

/**
 * ?�요??util ?�의??class.
 * 
 * @author JUNHO
 */
public class Util {
    private static PowerManager.WakeLock sCpuWakeLock;

	/**
	 * url ?�팅??
	 * 
	 * @param page
	 *            ?�로?�콜?�의?�에 ?�의??PAGE ?�름.
	 * @return URL 리턴.
	 */
	public static String getUrl(String page) {
		String url;
		// TEST URL
		// url = "http://tpiece.dyndns.org:8080/CafeNoa/" + page+".jsp?";;
		// 상용 URL
		url = "http://rouge3351.cafe24.com/" + page + ".jsp?";
		return url;
	}

	/**
	 * ?�드?�의 ?�화번호�??�어??
	 * 
	 * @param context
	 * @return
	 */
	public static String getPhoneNum(Context context) {
		TelephonyManager telManager = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		String phoneNum = telManager.getLine1Number();
		return phoneNum;

	}

	/**
	 * CPU가 Sleep모드로 들어갈시 다시 되살림.
	 * 
	 * @param context
	 */
	public static void acquireCpuWakeLock(Context context) {
		Log.i("Util", "Acquire cpu wake lock");
		if (sCpuWakeLock != null) {
			return;
		}
		PowerManager pm = (PowerManager) context
				.getSystemService(Context.POWER_SERVICE);
		sCpuWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
				| PowerManager.ACQUIRE_CAUSES_WAKEUP
				| PowerManager.ON_AFTER_RELEASE, "Util");
		sCpuWakeLock.acquire();
	}

	public static void releaseCpuLock() {
		Log.i("Util", "Releasing cpu wake lock");
		if (sCpuWakeLock != null) {
			sCpuWakeLock.release();
			sCpuWakeLock = null;
		}
	}
}
